<!DOCTYPE html>
<html>

<head>
	<meta charset="utf-8">
	<meta name="format-detection" content="telephone=no">
	<meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
	<meta name="apple-mobile-web-app-capable" content="yes">
	<meta name="apple-mobile-web-app-status-bar-style" content="black">
	<title>拼字</title>
	<link rel="stylesheet" type="text/css" href="css/base.css">
	<link rel="stylesheet" type="text/css" href="css/success.css" />
	<link rel="stylesheet" type="text/css" href="css/mui.min.css" />
	<script src="js/rem.js" type="text/javascript" charset="utf-8"></script>
</head>

<body>
	<div class="content">
		<div class="game-title">
			<img src="./image/success-font.png" alt="">
		</div>
		<div class="game-title-font">
			恭喜您获得了
		</div>
		<div class="gift">
			<img src="./image/gift.png" alt="">
		</div>
		<div class="gift-msg">
			<!-- <span>100</span>元日租卡 -->
		</div>
		<div class="game-res">
			<div class="share">查看奖品</div>
			<div class="continue">继续挑战</div>
		</div>
	</div>
</body>
<script src="js/jquery.min.js" type="text/javascript" charset="utf-8"></script>
<script src="js/mui.min.js"></script>
<script src="libs/base.js"></script>
<script src="js/jweixin-1.0.0.js"></script>
<script type="text/javascript">
	isUserInfo(function () {
		if (localStorage.getItem('isGift') == 1) {
			location.href = 'index.html';
		} else {
			wxFunction(function () {
				wx.ready(function () {
					wx.getLocation({
						type: 'wgs84', // 默认为wgs84的gps坐标，如果要返回直接给openLocation用的火星坐标，可传入'gcj02'
						success: function (res) {
							var latitude = res.latitude; // 纬度，浮点数，范围为90 ~ -90
							var longitude = res.longitude; // 经度，浮点数，范围为180 ~ -180。
							console.log(res);
							businessgift(longitude, latitude, function (res) {
								addgifts(res.id, function (data) {
									localStorage.setItem('isGift', 1);
								})
								$('.gift-msg').html(res.name);
							})
						}
					});
				}); 
			})
			// 获取商品
			function businessgift(jd, wd, fn) {
				ajax.request({
					params: {
						action: 'businessgift',
						wxopenid: wxopenid,
						wxuserjd: jd,
						wxuserwd: wd
					},
					callback: function (data) {
						fn(data);
					}
				})
			}
			// 记录商品
			function addgifts(giftid, fn) {
				ajax.returnRequest({
					params: {
						action: 'addgifts',
						wxopenid: wxopenid,
						giftid: giftid,
					},
					callback: function (data) {
						fn(data);
					}
				})
			}

			// businessgift('34.284453', '108.954163', function (res) {
			// 	console.log(res)
			// 	addgifts(1, function (data) {
			// 		console.log(data);
			// 		// picurl = res.picurl;
			// 	})
			// 	$('.gift-msg').html(res.name);
			// })

			$('.share').click(function () {
				location.href = 'details.html';
			})
			$('.continue').click(function () {
				location.href = 'index.html';
			})
		}
	})
</script>

</html>